<%--
  Created by IntelliJ IDEA.
  User: hp
  Date: 2020/7/12
  Time: 23:48
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="true" %>
<html>
<head>
    <title>库存清单</title>
    <%@include file="/common/com.jsp"%>
</head>
<body>
<div id="root">
    <template>
        <Collapse active-key="1">
            <Panel name="Panel">
                多条件查询
                <p slot="content">
                    <i-form :label-width="60" inline>
                        <Form-Item label="商品类型">
                            <i-input type="text" v-model="GoodsVo.type"></i-input>
                        </Form-Item>
                        <Form-Item label="供应商">
                            <i-Select v-model="GoodsVo.supperId" remote :remote-method="getsupperlist">
                                <i-Option :value="''">--查看全部--</i-Option>
                                <i-Option v-for="supper in supperlist" :value="suppli.id" :key="suppli.id">{{supper.supperName}}</i-Option>
                            </i-Select>
                        </Form-Item>
                        <i-button type="primary" shape="circle" icon="ios-search" @click="pageNo=1;getGoodslist();" >搜索</i-button>
                    </i-form>
                </p>
            </Panel>
        </Collapse>

    </template>
    <card>
        <i-button type="primary" shape="circle" @click="getGoodslist()"><Icon type="ios-refresh"></Icon>刷新</i-button>
    </card>

    <i-table :columns="columns" :data="data" border stripe height="400">
        <template slot-scope="{row,index}" slot="action3">
            {{row.supper.supperName}}
        </template>
        <template slot-scope="{row,index}" slot="action">
            <i-Button type="error"@click="del(row,index)">删除</i-Button>
        </template>
    </i-table>


    <template>
        <Page :total="total"
              show-elevator
              :page-size="pageSize"
              style="margin-left: 340px;margin-top:15px"
              :current.sync="pageNo"
              show-sizer
              prev-text="上一页"
              next-text="下一页"
              :page-size-opts="[5,10,20,30,40]"
              show-total
              @on-page-size-change="pageSize=arguments[0];getGoodslist();"
              @on-change="getGoodslist"/>
    </template>
</div>
</body>
<script>
    new  Vue({
        el:"#root",
        data:{
            columns:[
                {title:"商品名称",key:"name"},
                {title:"库存数量",key:"quantity"},
                {title:"商品类型",key:"type"},
                {title:"销售价格",key:"costprice"},
                {title:"成本价格",key:"sellingprice"},
                {title:"供应商",slot:"action3"},
                {title:"其他操作",slot:"action"}
            ],
            data:[],
            GoodsVo:{},
            total:50,
            pageNo:1,
            pageSize:5,
            Goods:{},
            Delivered:{},
            qquantity:1,


        },
        mounted(){
            this.getGoodslist();
        },
        methods:{
            getGoodslist(){
                axios.get(`${apath}/goods/pagelist/${this.pageSize}/${this.pageNo}`,{params:this.GoodsVo})
                    .then(({data})=>{
                        console.log(data.result);
                        this.data=data.result.record;
                        this.total=data.result.total;
                    })
            },
            del(row,index){
                let _this=this;
                iview.Modal.confirm({
                    title:"是否确定删除?",
                    content:"此操作一旦确定无法返回,请谨慎使用",
                    onOk(){
                        axios.get(`${apath}/goods/goodsdel/${row.id}`)
                            .then(({data})=>{
                                iview.Message.success({content: data.msg})
                                _this.getGoodslist();
                            })
                    },

                    onCancel(){
                        iview.Message.warning({
                            content:"取消删除"
                        })
                    }
                })
            },


        }

    })
</script>
</html>